package clienteremotoclásico;

import ejb.FachadaRemote;
import java.util.Date;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import modelo.Persona;

public class ClienteFachada {

    public static void main(String[] args) throws NamingException {
        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial",
                "com.sun.enterprise.naming.SerialInitContextFactory");
        props.setProperty("java.naming.factory.url.pkgs",
                "com.sun.enterprise.naming");
        props.setProperty("java.naming.factory.state",
                "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        // optional.  Defaults to localhost.  Only needed if web server is running
        // on a different host than the appserver   
        props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
        // optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
        props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
        
        Context ctx = new InitialContext(props);
        FachadaRemote fachada = (FachadaRemote) ctx.lookup("java:global/ProyectoJ2EE/ProyectoJ2EE-ejb/Fachada!ejb.FachadaRemote");
/*
        fachada.insertarPersona("Juan", new Date(), true);
        Persona per = new Persona("Ana", false ,new Date() );
        fachada.insertarPersona(per);
        Persona hallada = fachada.buscar(2);
        hallada.setNombre("Anónimo");
        fachada.actualizar(hallada);
*/        
/*        
        Persona per1 = new Persona("Ramón", true ,new Date() );
        fachada.actualizar(per1);
*/      
        Persona per1 = new Persona("1", true ,new Date() );
        Persona per2 = new Persona("2", true ,new Date() );
        Persona per3 = new Persona("3", true ,new Date() );
        per2.setId(2);
        fachada.insertar3Personas(per1, per2, per3);
    }
}
